<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="firstName='li'">change</button>
        <input type="text" v-model="firstName">
        <h1>{{fullName()}}</h1><!-- 每次调用函数都会重复计算,我们希望只要依赖的数据不发生改变,则不需要重新计算,而是把第一次计算的值缓存起来 -->
        <h1>{{fullName()}}</h1>
        <h1>{{fullName()}}</h1>
        <h1>{{fullName()}}</h1>
        <h1>{{fullName()}}</h1>
        <h1>{{fullName()}}</h1>
    </div>
    <script>
        Vue.config.productionTip = false;
        
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    firstName: "Wang",
                    lastName: "zhongwang",
                }
            },
            methods: {
                fullName() {
                    console.log('计算');
                    return this.firstName + " " + this.lastName;
                }
            }
        })
</script>
</body>

</html>